import { skipWaiting, clientsClaim, setCacheNameDetails } from 'workbox-core'
import { registerRoute  } from 'workbox-routing'
import {
    NetworkFirst, CacheFirst, StaleWhileRevalidate } from 'workbox-strategies'
import { CacheableResponsePlugin } from 'workbox-cacheable-response'
import {
    ExpirationPlugin
} from 'workbox-expiration'
import {
    precacheAndRoute,

} from 'workbox-precaching'

setCacheNameDetails({
    prefix: 'prefix',
    suffix: 'v1.0',
    precache: 'precache',
    runtime: 'runtime',
});

skipWaiting()
clientsClaim()

precacheAndRoute([{"revision":"caa272bc9a1a5fea1314d3905c6a316d","url":"assets/fonts/graduate.ttf"},{"revision":"b3259bac10272c9d1fe8ed9d682c978d","url":"css/index.css"},{"revision":"d37c193a181e5458ba0de805c7666a9c","url":"generateSW/config.js"},{"revision":"937bf268495b32b3089b6a2c526e00a1","url":"generateSW/index.js"},{"revision":"5c035e31d348d59c059cac3c9e0f172c","url":"index.html"},{"revision":"d37c193a181e5458ba0de805c7666a9c","url":"injectManifest/config.js"},{"revision":"196a34ddc8fbad1f6951ddd6383e7961","url":"injectManifest/index.js"},{"revision":"cf2fb6c7f8754081643c71ced79d9bd1","url":"js/index.js"},{"revision":"caf29fd274cee53513bb2f4333470b2f","url":"rollup.config.js"},{"revision":"c6bfe3de8bb41796bc5452f6e2141702","url":"service-worker.js"},{"revision":"2cb1828f78cbea8b7a17f389de565734","url":"sw.js"}])

registerRoute(
    new RegExp(/^http:\/\/juheimg.oss-cn-hangzhou.aliyuncs.com/),
    new NetworkFirst({
        cacheName: 'images',
        plugins: [
            new CacheableResponsePlugin({
                statuses: [200],
            }),
            new ExpirationPlugin({
                maxEntries: 50,
                maxAgeSeconds: 60 * 60 * 24 * 30, // 30 Days
            }),
        ],
    }),
);



registerRoute(
    // ({ request }) => request.url === 'http://localhost:3030/api/food/getFoodList',
    new RegExp(/^http:\/\/localhost:3030/),
    new NetworkFirst({
        // cacheName: 'api',
        plugins: [
            new CacheableResponsePlugin({
                statuses: [200],
            }),
            new ExpirationPlugin({
                maxEntries: 50,
                maxAgeSeconds: 60 * 60 * 24 * 30, // 30 Days
            }),
        ],
    }),
);

